@extends('admin.common.admin')

@section('cnt')
    {{-- 面包屑导航 --}}
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 接口账号管理
        <span class="c-gray en">&gt;</span> 添加接口账号
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
           href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <article class="page-container">
        {{-- 消息提示 --}}
        @include('admin.common.msg')

        <form class="form form-horizontal" id="useradd" method="post" action="{{ route('admin.apiuser.store') }}">
            @csrf
            <div class="row cl">
                <label class="form-label col-sm-2"><span class="c-red">*</span>账号：</label>
                <div class="formControls col-sm-10">
                    <input type="text" class="input-text" value="{{ old('username') }}" name="username">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-2"><span class="c-red">*</span>密码：</label>
                <div class="formControls col-sm-10">
                    <input type="text" class="input-text" autocomplete="off" value="{{ old('password') }}" name="password">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-2"><span class="c-red">*</span>Token：</label>
                <div class="formControls col-sm-10">
                    <input type="text" class="input-text" value="{{ old('token') }}" name="token">
                </div>
            </div>
            <div class="row cl">
                <div class="col-sm-10 col-sm-offset-2">
                    <input class="btn btn-primary radius" type="submit" value="添加接口账号">
                </div>
            </div>
        </form>
    </article>
@endsection
@section('js')
    <script>
        $("#useradd").validate({
            // 验证规则
            rules: {
                // 名称，表单域的name名称
                username: { // 规则
                    required: true,
                    minlength: 2
                },
                password: {
                    required: true
                },
                token: {
                    required: true
                }
            },
            // 取消回车事件
            onkeyup: false,
            // 验证成功时的样式名称
            success: "valid",
            // 验证成功后，回调事件  form dom对象
            submitHandler: function (form) {
                // js 表单提交
                form.submit();
            }
        });
    </script>
@endsection

